package top.hidoctor.auscultation.feature.activity;

import android.bluetooth.BluetoothDevice;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import top.hidoctor.auscultation.R;
import top.hidoctor.auscultation.base.BaseActivity;

import static top.hidoctor.auscultation.feature.activity.DeviceActivity.BLUETOOTH_DEVICE;

public class LabelActivity extends BaseActivity {

    private BluetoothDevice device;
    private TextView tvNumber, tvStatus;
    private View viewStatus;
    private Button btnYindao;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_label);
        device = getIntent().getParcelableExtra(BLUETOOTH_DEVICE);
        initView();
    }


    private void initView() {
        Toolbar toolbar = findViewById(R.id.toolbar);
        toolbar.setNavigationIcon(R.mipmap.ic_back_left);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        tvNumber = findViewById(R.id.tv_number);
        tvStatus = findViewById(R.id.tv_status);
        btnYindao = findViewById(R.id.btn_yindao);
        viewStatus = findViewById(R.id.view_status);
        if (device != null) {
            tvNumber.setText(device.getAddress());
            tvStatus.setText("在线");
            viewStatus.setBackground(getResources().getDrawable(R.drawable.green_point));
        } else {
            tvStatus.setText("离线");
            viewStatus.setBackground(getResources().getDrawable(R.drawable.red_point));
        }

        btnYindao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(LabelActivity.this, TzGatherActivity.class);
                intent.putExtra(BLUETOOTH_DEVICE, device);
                startActivity(intent);
            }
        });
    }
}
